package crawler.web.engine.config;

/**
 * 
 * @author waynechen
 * 
 */
public class Suite {
	public interface IType {
		public int getValue();

		public String getExpr();
	}

	public static String enumValue2Expr(IType[] values, int value) {
		for (IType t : values)
			if (t.getValue() == value)
				return t.getExpr();
		return "";
	}

	/**
	 * context的狀態
	 */
	public enum ParseStatus implements IType {
		DOWNLOAD(1, "HTML下载完成"), //
		PARSED(2, "html -> 结构化"), //
		DEDUPLICATED(3, "结构化 -> 去重"), //
		FIND_SIMILAR_FINGER_PRINT(4, "去重 -> 查找相似数据"), //
		ERROR(-1, "错误状态");

		private final int value;
		private final String expr;

		private ParseStatus(int value, String expr) {
			this.value = value;
			this.expr = expr;
		}

		@Override
		public int getValue() {
			return value;
		}

		@Override
		public String getExpr() {
			return expr;
		}
	}

	/**
	 * div 类型
	 */
	public enum DivType implements IType {
		MAIN(1, "主体内容"), //
		GARBAGE(2, "广告/垃圾内容"), //
		COMMENT(3, "列表/评论"), //
		OTHER(4, "其它"), //
		ERROR(-1, "错误状态");

		private final int value;
		private final String expr;

		private DivType(int value, String expr) {
			this.value = value;
			this.expr = expr;
		}

		@Override
		public int getValue() {
			return value;
		}

		@Override
		public String getExpr() {
			return expr;
		}
	}

	/**
	 * 网页 类型<br/>
	 * 注意* 为了导数据方便, 这里使用, expr
	 */
	public enum PageType implements IType {
		SIGHT(1, "景点"), //
		FOOD(2, "美食"), //
		GOOD(3, "商品"), //
		GARBAGE(4, "广告/垃圾内容"), //
		ERROR(-1, "错误状态");

		private final int value;
		private final String expr;

		private PageType(int value, String expr) {
			this.value = value;
			this.expr = expr;
		}

		@Override
		public int getValue() {
			return value;
		}

		@Override
		public String getExpr() {
			return expr;
		}
	}
}